package com.sgb.kjwl.model.entity.transport;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author: 杨畔
 * @date: 2021/1/26 09:35
 * @Description: 发布货源计算距离实体
 */
public class CargoDistanceEntity implements Parcelable {

    private Double totalDistance;//总距离
    private Double firstDistance;//距离1
    private Double secondDistance;//距离2
    private Double thirdDistance;//距离3

    public CargoDistanceEntity() {
    }

    protected CargoDistanceEntity(Parcel in) {
        if (in.readByte() == 0) {
            totalDistance = null;
        } else {
            totalDistance = in.readDouble();
        }
        if (in.readByte() == 0) {
            firstDistance = null;
        } else {
            firstDistance = in.readDouble();
        }
        if (in.readByte() == 0) {
            secondDistance = null;
        } else {
            secondDistance = in.readDouble();
        }
        if (in.readByte() == 0) {
            thirdDistance = null;
        } else {
            thirdDistance = in.readDouble();
        }
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (totalDistance == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeDouble(totalDistance);
        }
        if (firstDistance == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeDouble(firstDistance);
        }
        if (secondDistance == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeDouble(secondDistance);
        }
        if (thirdDistance == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeDouble(thirdDistance);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<CargoDistanceEntity> CREATOR = new Creator<CargoDistanceEntity>() {
        @Override
        public CargoDistanceEntity createFromParcel(Parcel in) {
            return new CargoDistanceEntity(in);
        }

        @Override
        public CargoDistanceEntity[] newArray(int size) {
            return new CargoDistanceEntity[size];
        }
    };

    public Double getFirstDistance() {
        return firstDistance;
    }

    public void setFirstDistance(Double firstDistance) {
        this.firstDistance = firstDistance;
    }

    public Double getTotalDistance() {
        return totalDistance;
    }

    public void setTotalDistance(Double totalDistance) {
        this.totalDistance = totalDistance;
    }

    public Double getSecondDistance() {
        return secondDistance;
    }

    public void setSecondDistance(Double secondDistance) {
        this.secondDistance = secondDistance;
    }

    public Double getThirdDistance() {
        return thirdDistance;
    }

    public void setThirdDistance(Double thirdDistance) {
        this.thirdDistance = thirdDistance;
    }
}
